<?php

/*
  //充值
  $param=array(
  'FUUID'=>time(),
  'FFGOPer'=>'brivio',
  'FISMOBILEPHONENUM'=>null,
  'FMOBILEPHONENUM'=>null,
  'FCARDNUM'=>'060571003596',
  'FOccur'=>1,
  'FOldNum'=>null,
  'FNote'=>'测试',
  'FCHECKSRCTRANS'=>0

  );
  $res=$card->exec("REFUNDDEPOSIT",$param);
  print_r($res);exit;
  exit;
 */
if (!defined('IN_ECS')) {
    die('Hacking attempt');
}
class cls_card {

    var $url = "http://218.108.4.136/HDCRMWebService.dll/wsdl/IHDCRMWebService";
    var $name = "1004220";
    var $pwd = "D67B697E13B2DB6B";
    var $client;
    var $sClientCookie;
    var $proxy;

    function cls_card($url, $name, $pwd) {
        $this->url = $url;
        $this->name = $name;
        $this->pwd = $pwd;
    }

    function Login() {
        $this->client = new soapclient($this->url, true);
        //$this->client->setHTTPProxy($this->url,"80",$this->name,$this->pwd);
        $this->client->setUseCURL(true);
        $this->client->decode_utf8 = false;
        $this->client->xml_encoding = 'utf-8';
        $this->proxy = $this->client->getProxy();
        $res = $this->proxy->LogIn("1004220['优谷大地']", '9190', '961882', $this->name, $this->pwd);
        $this->sClientCookie = $res['sClientCookie'];
    }

    function Logout() {
        $this->client = new SoapClient($this->url, true);
        $this->client->decode_utf8 = false;
        $this->client->xml_encoding = 'utf-8';
        $this->proxy = $this->client->getProxy();

        $this->proxy->LogOut($this->sClientCookie);
    }

    function exec($sCommand, $params) {
        $this->Login();
        $sParams = "[\]\n";
        foreach ($params as $key => $val) {
            $sParams.=$key . "=" . $val . "\n";
        }
        $res = $this->proxy->DoClientCommand($this->sClientCookie, $sCommand, $sParams);
        
        if($res){
            $res['sOutParams']=str_replace("[\\]",'[Def]',$res['sOutParams']);
            $res['sOutParams']=parse_ini_string($res['sOutParams'],true);
        }
        //print_r($res);exit;
        return $res;
    }
}

?>
